<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
//use Illuminate\Support\Facades\Schema;

class CreateMiniProgramSetting extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('mini_program_special')) {
            Schema::create('mini_program_special', function (Blueprint $table) {
                $table->id();
                $table->string('mini_type', 50)->comment('小程序类型');
                $table->string('type', 50)->default('index')->comment('类型：index-首页');
                $table->string('module_slug')->comment('模块标识');
                $table->integer('sort')->default(0)->comment('排序值');
                $table->tinyInteger('is_show')->default(1)->comment('是否显示 1-是 0-否');
                $table->index(['mini_type', 'is_show']);
                $table->timestamps();
                $table->comment = '小程序专题页模块配置';
            });
        }

        if (!Schema::hasTable('mini_program_bottom_tab')) {
            Schema::create('mini_program_bottom_tab', function (Blueprint  $table){
                $table->id();
                $table->string('mini_type', 50)->comment('小程序类型');
                $table->string('icon')->comment('未选中图标');
                $table->string('s_icon')->comment('选中后图标');
                $table->string('name')->comment('名称');
                $table->string('action')->comment('动作');
                $table->text('data')->nullable()->comment('参数');
                $table->integer('sort')->default(0)->comment('排序值');
                $table->tinyInteger('is_show')->default(1)->comment('是否显示 1-是 0-否');
                $table->index(['mini_type', 'is_show']);
                $table->timestamps();
                $table->comment = '小程序底部tab';
            });
        }

        if (!Schema::hasTable('template_message')) {
            Schema::create('template_message', function (Blueprint $table) {
                $table->id();
                $table->string('mini_type', 50)->index()->comment('小程序类型');
                $table->string('template_id')->comment('模板id');
                $table->string('type')->comment('类型');
                $table->tinyInteger('status')->comment('状态 1-正常 0-禁止');
                $table->timestamps();
                $table->comment = '小程序模板消息';
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mini_program_special');
        Schema::dropIfExists('mini_program_bottom_tab');
        Schema::dropIfExists('template_message');
    }
}
